package com.reader.api.config;

import com.reader.api.interceptor.AuthorizationInterceptor;
import com.reader.api.interceptor.MemberCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置 add by jiahaikun
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Autowired
    private MemberCheckInterceptor memberCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // UI API 拦截器
       registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**");
        // 会员过期检查 拦截器
     //   registry.addInterceptor(memberCheckInterceptor).addPathPatterns("/api/**");

        // 开放openapi 拦截器
//        registry.addInterceptor(authorizationOpenAPIInterceptor).addPathPatterns("/openapi/**");
    }

}
